<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: FWMath Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00095.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-static-methods">Static Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">FWMath Class Reference<div class="ingroups"><a class="el" href="a00514.html">utils  -  utility classes</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="FWMath" -->
<p>Support functions for mathematical operations.  
 <a href="a00095.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00393_source.html">FWMath.h</a>&gt;</code></p>

<p><a href="a00755.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a2867eea5a97b7685de513a989046f699">mod</a> (double dividend, double divisor)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a76f6d077fea756cc254c9405d0b51708">div</a> (double dividend, double divisor)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#adfee479fcdbaba84bd4cfa57cdacf97e">modulo</a> (double a, double n)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a38d2500887b49de2a2b5f8610f7ba6d1">close</a> (double one, double two)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a4d2b3271455f9f914bd85c0e22064c09">stepfunction</a> (double i)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#aa9f55c74f3cb5eb99d5ff3d00ca3d281">sign</a> (double i)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#ad5b2d4a46bf7af77e9cc0070b6a82c18">round</a> (double d)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#adb95c6d5b092b752dba10eddac28055d">floorToZero</a> (double d)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#a7fd5acab90d26f509178dbda7935adcf">max</a> (double a, double b)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#af308407856d9835b103f2421e373ee28">dBm2mW</a> (double dBm)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00095.html#af1390153a78142efb6af6225034f954f">mW2dBm</a> (double mW)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Support functions for mathematical operations. </p>
<p>This class contains all kind of mathematical support functions</p>
<dl class="author"><dt><b>Author:</b></dt><dd>Christian Frank </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a38d2500887b49de2a2b5f8610f7ba6d1"></a><!-- doxytag: member="FWMath::close" ref="a38d2500887b49de2a2b5f8610f7ba6d1" args="(double one, double two)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static bool FWMath::close </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>one</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>two</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Tests whether two doubles are close enough to be declared equal. Returns true if parameters are at most epsilon apart, false otherwise </p>

<p>Referenced by <a class="el" href="a00179.html#abe806a2afdeb239694094c24446f699f">PostureTransition::isMarkovian()</a>.</p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> fabs(one-two)&lt;EPSILON; }
</pre></div>
</div>
</div>
<a class="anchor" id="af308407856d9835b103f2421e373ee28"></a><!-- doxytag: member="FWMath::dBm2mW" ref="af308407856d9835b103f2421e373ee28" args="(double dBm)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::dBm2mW </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>dBm</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Converts a dBm value into milliwatts </p>

<p>Referenced by <a class="el" href="a00227.html#ade7fd8114864ff11327435c57cab0e53">WiseRoute::initialize()</a>, <a class="el" href="a00128.html#ab81dae24d79c2ef010301e2c219966c1">Mac80211::initialize()</a>, <a class="el" href="a00029.html#a08704deaf03b73c8eda67cc60e670853">BasePhyLayer::initialize()</a>, and <a class="el" href="a00127.html#ab81e4e559d16d59321fe0dced4a45806">LogNormalShadowing::randomLogNormalGain()</a>.</p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> pow(10.0, dBm/10.0); }
</pre></div>
</div>
</div>
<a class="anchor" id="a76f6d077fea756cc254c9405d0b51708"></a><!-- doxytag: member="FWMath::div" ref="a76f6d077fea756cc254c9405d0b51708" args="(double dividend, double divisor)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::div </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>dividend</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>divisor</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the result of a whole-numbered division. </p>
<div class="fragment"><pre class="fragment">                                                     {
      <span class="keywordtype">double</span> i;
      modf(dividend/divisor, &amp;i);
      <span class="keywordflow">return</span> i;
  }
</pre></div>
</div>
</div>
<a class="anchor" id="adb95c6d5b092b752dba10eddac28055d"></a><!-- doxytag: member="FWMath::floorToZero" ref="adb95c6d5b092b752dba10eddac28055d" args="(double d)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::floorToZero </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>d</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Discards the fractional part of the parameter, e.g. -3.8 becomes -3 </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (d &gt;= 0.0)? floor(d) : ceil(d); }
</pre></div>
</div>
</div>
<a class="anchor" id="a7fd5acab90d26f509178dbda7935adcf"></a><!-- doxytag: member="FWMath::max" ref="a7fd5acab90d26f509178dbda7935adcf" args="(double a, double b)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::max </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the greater of the given parameters </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (a&lt;b)? b : a; }
</pre></div>
</div>
</div>
<a class="anchor" id="a2867eea5a97b7685de513a989046f699"></a><!-- doxytag: member="FWMath::mod" ref="a2867eea5a97b7685de513a989046f699" args="(double dividend, double divisor)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::mod </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>dividend</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>divisor</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the rest of a whole-numbered division. </p>
<div class="fragment"><pre class="fragment">                                                     {
      <span class="keywordtype">double</span> i;
      <span class="keywordflow">return</span> modf(dividend/divisor, &amp;i)*divisor;
  }
</pre></div>
</div>
</div>
<a class="anchor" id="adfee479fcdbaba84bd4cfa57cdacf97e"></a><!-- doxytag: member="FWMath::modulo" ref="adfee479fcdbaba84bd4cfa57cdacf97e" args="(double a, double n)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::modulo </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>n</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the remainder r on division of dividend a by divisor n, using floored division. The remainder r has the same sign as the divisor n. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (a - n * floor(a/n)); }
</pre></div>
</div>
</div>
<a class="anchor" id="af1390153a78142efb6af6225034f954f"></a><!-- doxytag: member="FWMath::mW2dBm" ref="af1390153a78142efb6af6225034f954f" args="(double mW)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static double FWMath::mW2dBm </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>mW</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Convert a mW value to dBm. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (10 * log10(mW)); }
</pre></div>
</div>
</div>
<a class="anchor" id="ad5b2d4a46bf7af77e9cc0070b6a82c18"></a><!-- doxytag: member="FWMath::round" ref="ad5b2d4a46bf7af77e9cc0070b6a82c18" args="(double d)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static int FWMath::round </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>d</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns an integer that corresponds to rounded double parameter </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)(ceil(d-0.5)); }
</pre></div>
</div>
</div>
<a class="anchor" id="aa9f55c74f3cb5eb99d5ff3d00ca3d281"></a><!-- doxytag: member="FWMath::sign" ref="aa9f55c74f3cb5eb99d5ff3d00ca3d281" args="(double i)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static int FWMath::sign </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>i</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns 1 if the parameter is greater or equal to zero, -1 otherwise </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (i&gt;=0)? 1 : -1; };
</pre></div>
</div>
</div>
<a class="anchor" id="a4d2b3271455f9f914bd85c0e22064c09"></a><!-- doxytag: member="FWMath::stepfunction" ref="a4d2b3271455f9f914bd85c0e22064c09" args="(double i)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static int FWMath::stepfunction </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>i</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns 0 if i is close to 0, 1 if i is positive and greater than epsilon, or -1 if it is negative and less than epsilon. </p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> (i&gt;EPSILON) ? 1 : <a class="code" href="a00095.html#a38d2500887b49de2a2b5f8610f7ba6d1">close</a>(i, 0) ? 0 :-1; };
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/util/<a class="el" href="a00393_source.html">FWMath.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00095.html">FWMath</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
